/*******************************************************************
 * 外语翻译平台(translate) 
 *
 * 成都一亿信息技术公司 版权所有
 * 
 * Copyright (C) 2010 Transer Information Technology Co., Ltd.
 *
 * @Version : 1.0  2011-2-25 下午07:53:25
 *
 * UpdateDetailAction.java 
 *
 *******************************************************************/
package com.transer.web.action.passport;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;

import com.transer.persistance.bean.User;
import com.transer.persistance.dao.IUserDao;
import com.transer.web.action.TranserActionSupport;

/**
 * class defination are there
 * 
 * @author Mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
public class UpdateDetailAction extends TranserActionSupport {

	private static final long serialVersionUID = -2432887429631179223L;
	// 日志操作
	private static final Logger logger = Logger.getLogger(UpdateDetailAction.class);
	// 用户操作
	private IUserDao userDao;
	// 擅长类型
	private User dump;
	// 消息
	private String message;
	// 用户备份数据
	private User copy;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		// /goodAt=50001&dump.realName=&dump.cellPhone=&dump.alipay=&dump.im=&dump.provice=0&dump.city=0&dump.experience=0&dump.college=
		try {
			// 备份用户数据
			copy = (User) BeanUtils.cloneBean(user);
			// 真实姓名
			user.setRealName(dump.getRealName());
			// 手机号码
			user.setCellPhone(dump.getCellPhone());
			// 支付宝
			user.setAlipay(dump.getAlipay());
			// 即时通信
			user.setIm(dump.getIm());
			// 省份
			user.setProvice(dump.getProvice());
			// 城市
			user.setCity(dump.getCity());
			// 翻译经验
			user.setExperience(dump.getExperience());
			// 毕业大学
			user.setCollege(dump.getCollege());
			// 保存用户
			userDao.updateUser(user);
			// 保存成功
			message = TranserActionSupport.SUCCESS;
		} catch (Exception e) {
			logger.error("更新用户数据出错:" + e.getMessage());
			// 保存失败
			message = TranserActionSupport.ERROR;
			// 保存错误,不愿用户数据
			BeanUtils.copyProperties(user, copy);
		}
		return message;
	}

	/**
	 * @return the userDao
	 */
	public IUserDao getUserDao() {
		return userDao;
	}

	/**
	 * @param userDao
	 *            the userDao to set
	 */
	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	/**
	 * @return the dump
	 */
	public User getDump() {
		return dump;
	}

	/**
	 * @param dump
	 *            the dump to set
	 */
	public void setDump(User dump) {
		this.dump = dump;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message
	 *            the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

}
